package com.fsserver.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Knife4j配置类
 * Knife4j Configuration
 *
 * @author fsserver
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {

    /**
     * 创建API文档配置
     * Create API documentation configuration
     *
     * @return Docket对象
     */
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("支付服务接口")
                .select()
                // 指定扫描的包路径
                // Specify the package path to scan
                .apis(RequestHandlerSelectors.basePackage("com.fsserver.web"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * 创建API基本信息
     * Create API basic information
     *
     * @return ApiInfo对象
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                // 文档标题
                // Document title
                .title("支付服务API文档")
                // 文档描述
                // Document description
                .description("支付服务接口文档，提供支付、退款、对账等功能的API接口")
                // 服务条款URL
                // Terms of service URL
                .termsOfServiceUrl("https://www.example.com/")
                // 联系人信息
                // Contact information
                .contact(new Contact("fsserver", "https://www.example.com/", "contact@example.com"))
                // 版本号
                // Version
                .version("1.0.0")
                .build();
    }
} 